import {request} from "umi";
import ServiceEnvs from "@/services/ServiceEnvs";
import {getUserInfo} from "@/utils/format";

const baseUrl = ServiceEnvs.baseUrl

// 参数形式 username=xuz1&password=123456&roleidLogin=3
export const LoginAPI = (queryString: string) => {
  return request(baseUrl+'/api/login', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8',
    },
    data: queryString,
  })
}

export const Auth2LoginAPI = (queryString: string) => {
  return request(baseUrl+'/api/auth2login'+queryString, {
    method: 'GET',
  })
}

//username=xuz1&password=123456&disciplinecode=890&jobnumber=890&phonenumber=890
export const RegisterAPI = (queryString: string) => {
  const userInfo = getUserInfo()
  return request(baseUrl+'/api/register', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8',
      'Authorization': userInfo.token
    },
    data: queryString,
  })
}
